<?PHP
require_once WACT_ROOT.'controller/controller.inc.php';
require_once APP_ROOT.'view/pub/layoutright.view.php';
require_once APP_ROOT.'model/common/session.php';
require_once APP_ROOT.'model/common/user.php';
require_once APP_ROOT.'model/common/article.php';
require_once APP_ROOT.'model/common/price.php';
require_once APP_ROOT.'model/common/date.php';
require_once APP_ROOT . "model/common/site.php";

class ArticlesPrintDetailView extends View {
	function ArticlesPrintDetailView($TemplateFile){
		parent::View($TemplateFile);

	}

	function prepare(&$controller, &$request, &$responseModel){
		parent::prepare(&$controller, &$request, &$responseModel);
		$docbase="http://".$_SERVER['HTTP_HOST'];
		$this->Template->set('docbase',$docbase);

		$article_id=$request->getParameter('id');

		$article=&Article::getRecord($article_id);

        
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
		$this->Template->set('title',Site::getTitle().' -  Print article - '.$article->get('headline'));


    

		$datestr=$article->get('date_added');
		$mydate=strtotime($datestr);
        $tz =& new MyTimeZone();
        $mydate = $tz->timeGMT($mydate);
		$datestr = gmstrftime('%b %d, %Y',$mydate);
		$this->Template->set('date_added',$datestr);

		$this->Template->set('headline',$article->get('headline'));
		$this->Template->set('firstname',$article->get('firstname'));
		$this->Template->set('lastname',$article->get('lastname'));
		$this->Template->set('author_title',$article->get('title'));
		$description=$article->get('description');

		$this->Template->set('description',$description);

	}

}

class ArticlesPrintTeaserView extends View {
	function View($TemplateFile){
		parent::LayoutRightView($TemplateFile);

	}
	function prepare(&$controller, &$request, &$responseModel){
		parent::prepare(&$controller, &$request, &$responseModel);
		$docbase="http://".$_SERVER['HTTP_HOST'];
		$this->Template->set('docbase',$docbase);

		$article_id=$request->getParameter('id');

		$article=&Article::getRecord($article_id);

                
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
		$this->Template->set('title',Site::getTitle().' - Print article teaser - '.$article->get('headline'));


	 

		$datestr=$article->get('date_added');
		$mydate=strtotime($datestr);
        $tz =& new MyTimeZone();
        $mydate = $tz->timeGMT($mydate);
		$datestr = gmstrftime('%b %d, %Y',$mydate);
		$this->Template->set('date_added',$datestr);

		$this->Template->set('headline',$article->get('headline'));
		$this->Template->set('firstname',$article->get('firstname'));
		$this->Template->set('lastname',$article->get('lastname'));
		$this->Template->set('author_title',$article->get('title'));
		$teaser=$article->get('teaser');
		if($teaser&&strlen($teaser)>0){
			$this->Template->set('teaser',$teaser);
		}
		//$price=&Price::getPriceByType(4);
		//$number=$price->get('price');
		//list($int,$dec)=explode('.',$number);
		//if(!($dec>0))
			//$this->Template->set('price',$int);
		$price =& Price::getPrice(4);
		$price1 =& Price::getPrice(1);
		$price2 =& Price::getPrice(2);
		$price3 =& Price::getPrice(3);

		$price = number_format($price,2);
		$price1 = number_format($price1,2);
		$price2 = number_format($price2,2);
		$price3 = number_format($price3,2);
		$this->Template->set('price',$price);
		$this->Template->set('price1',$price1);
		$this->Template->set('price2',$price2);
		$this->Template->set('price3',$price3);



	}


}

class ArticlesPrintDetailPage extends PageController {
	function ArticlesPrintDetailPage() {
		parent::PageController();
        $site_id = Site::getTemplateSiteID();
        $mytemplate1 = 'pub/articles/print_detail.html';
       

		$this->setDefaultView(new ArticlesPrintDetailView($mytemplate1));

	}


}

class ArticlesPrintTeaserPage extends PageController {
	function ArticlesPrintTeaserPage() {
		parent::PageController();
        $site_id = Site::getTemplateSiteID();
        $mytemplate1 = 'pub/articles/print_teaser.html';
       

		$this->setDefaultView(new ArticlesPrintTeaserView($mytemplate1));

	}


}


?>
